using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class OrderNoteMap : EntityTypeConfiguration<OrderNote>
    {
        public OrderNoteMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Note)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("OrderNote");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.OrderId).HasColumnName("OrderId");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.DownloadId).HasColumnName("DownloadId");
            this.Property(t => t.DisplayToCustomer).HasColumnName("DisplayToCustomer");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");

            // Relationships
            this.HasRequired(t => t.Order)
                .WithMany(t => t.OrderNotes)
                .HasForeignKey(d => d.OrderId);

        }
    }
}
